One of the most interesting and challenging aspects of formation guidance law design is the coupling of the orbit design and the science return. The analyst's role is more complicated than simply to design the formation geometry and evolution. He or she is also involved in designing a significant portion of the science instrument itself. The effectiveness of the formation as a science instrument is intimately coupled with the relative geometry and evolution of the collection of spacecraft. Therefore, the science return can be maximized by optimizing the orbit design according to a performance metric relevant to the science mission goals. In this work, we present a simple method for optimal formation guidance that is applicable to missions whose performance metric, requirements, and constraints can be cast as functions that are explicitly dependent upon the orbit states and spacecraft relative positions and velocities. We present a general form for the cost and constraint functions, and derive their semi-analytic gradients with respect to the formation initial conditions. The gradients are broken down into two types. The first type are gradients of the mission specific performance metric with respect to formation geometry. The second type are derivatives of the formation geometry with respect to the orbit initial conditions. The fact that these two types of derivatives appear separately allows us to derive and implement a general framework that requires minimal modification to be applied to different missions or mission phases. To illustrate the applicability of the approach, we conclude with applications to two missions: the Magnetospheric Multiscale mission (MMS) , and the Laser Interferometer Space Antenna (LISA).